/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main.Events;

import main.Events.Entity.EntityHitEvent;
import java.util.ArrayList;

/**
 *
 * @author usuario
 */
public class EventHandler {
    
    ArrayList<Event> events = new ArrayList<Event>();
    ArrayList<Event> removed = new ArrayList<Event>();
    public void callEvent(Event event) {
        events.add(event);
        System.out.println("add");
    }
    
    public void processEvents() {
        removed.clear();
        for(int x = 0 ; x < events.size() ; x++) {
                System.out.println("1");
                if(events.get(x).isCanceled()) continue;
                if(events.get(x).process())
                    removed.add(events.get(x));
        }
        events.removeAll(removed);
        
    }
    
}
